package com.hmdp.config;

import com.hmdp.interceptor.EveryInterceptor;
import com.hmdp.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Autowired
    private EveryInterceptor everyInterceptor;

    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(everyInterceptor).order(0);//第一重拦截，拦截所有请求

        registry.addInterceptor(loginInterceptor)//第二重请求
                .excludePathPatterns(
                        "/user/code",
                        "/user/login",
                        "/blog/hot",
                        "/blog/**",
                        "/shop/**",
                        "/upload/**",
                        "/shop-type/**",
                        "/voucher/**"
                ).order(1);


    }
}
